package com.ll.homework;

import java.util.*;

/**
 * @author 刘龙
 * @version 1.0
 */
public class Homework03 {
    public static void main(String[] args) {
        HashMap<String, Integer> employees = new HashMap<String, Integer>();
        employees.put("jack", 65);
        employees.put("tom", 1200);
        employees.put("smith", 2900);

        // 将jack的工资更改为1600
        employees.put("jack", 2600);

        // 为所有员工的工资加100元
        Set<String> strings1 = employees.keySet();
        for (String s : strings1) {
            employees.put(s, employees.get(s) + 100);
        }

        System.out.println(employees);


        //遍历所有员工
        Set<String> strings = employees.keySet();
        for (String string : strings) {
            System.out.print(string + "-" + employees.get(string));
        }

        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()) {
            String string = iterator.next();
            System.out.println(string + "-" + employees.get(string));
        }

        Set<Map.Entry<String, Integer>> entries = employees.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            Map.Entry m = (Map.Entry) entry;
            System.out.println(m.getKey() + "-" + m.getValue());
        }

        // 遍历所有员工的工资
        Collection<Integer> values = employees.values();
        for (Integer value : values) {
            System.out.println(value);
        }

    }
}
